using System.Collections;
using System.Collections.Generic;
using UnityEngine;


// 挂载于Enemy的子物体(视野)之上, 用来判断视野中出现主角
public class ViewPlayer : MonoBehaviour
{   

    [Header("运行时")]
    public bool bIsFindPlayer = false;
    
    private Enemy enemy;
    private void Start() {
        enemy = GetComponentInParent<Enemy>();
    }


    private void OnTriggerEnter2D(Collider2D other) {
        if (other.tag=="Player"){
            enemy.ViewPlayer(other.gameObject);
        }
    }

    private void OnTriggerExit2D(Collider2D other) {
        if (other.tag=="Player"){
            enemy.LostInViewPlayer();
        }
    }

}
